package com.example.pei.ithinklearnt.bean;


import android.content.Context;
import android.content.Intent;

import com.example.pei.ithinklearnt.AppApplication;
import com.example.pei.ithinklearnt.R;
import com.example.pei.ithinklearnt.db.NewComment;
import com.example.pei.ithinklearnt.db.dao.CommentDaoOrder;
import com.example.pei.ithinklearnt.view.activity.NewCommentActivity;


/**
 * 新回复会话
 * Created by Administrator on 2016/5/25.
 */
public class NewCommentConversation extends Conversation{

    private NewComment lastComment;

    public NewCommentConversation(NewComment friend){
        this.lastComment=friend;
        this.cName="新回复";
    }

    @Override
    public String getLastMessageContent() {
        if(lastComment!=null) {
            return lastComment.getContent();
        }
        return "";
    }

    @Override
    public long getLastMessageTime() {
        if(lastComment!=null){
            return lastComment.getTime();
        }else{
            return 0;
        }
    }

    @Override
    public Object getAvatar() {
        return R.mipmap.new_comments_icon;
    }

    @Override
    public int getUnReadCount() {
        return CommentDaoOrder.getInstance(AppApplication.getContext()).getNewCommentCount();
    }

    @Override
    public void readAllMessages() {
        //批量更新未读未认证的消息为已读状态
        CommentDaoOrder.getInstance(AppApplication.getContext()).updateBatchStatusReaded();
    }

    @Override
    public void onClick(Context context) {
        Intent intent = new Intent();
        intent.setClass(context, NewCommentActivity.class);
        context.startActivity(intent);
    }

    @Override
    public void onLongClick(Context context) {
      //  CommentDaoOrder.getInstance(context).deleteNewFriend(lastFriend);
        //全部更新为删除 除非有新回复通知否则不显示 。但是本地数据库并没有删除
        CommentDaoOrder.getInstance(AppApplication.getContext()).updateBatchStatusDeleted();


    }
}
